using System;
using System.Configuration;
using System.Net.Mime;
using System.Web;

/// <summary>
/// Summary description for Utils
/// </summary>
public class Utils
{
	public static string GetMediaTypeByExtension(string extension)
	{
		string mediaType = MediaTypeNames.Application.Octet;
		if(string.IsNullOrEmpty(extension))
			return mediaType;
		
		if(extension[0] == '.')
			extension = extension.Substring(1);

		if(string.Equals(extension, "gif", StringComparison.OrdinalIgnoreCase))
			mediaType = MediaTypeNames.Image.Gif;
		else if(string.Equals(extension, "jpg", StringComparison.OrdinalIgnoreCase) ||
			string.Equals(extension, "jpeg", StringComparison.OrdinalIgnoreCase))
			mediaType = MediaTypeNames.Image.Jpeg;
		else if(string.Equals(extension, "png", StringComparison.OrdinalIgnoreCase))
			mediaType = "image/png";
		else if(string.Equals(extension, "bmp", StringComparison.OrdinalIgnoreCase))
			mediaType = "image/bmp";

		return mediaType;
	}
}
